package com.example;

public class ThreadCreateByRunnable {

    public static class TestTask implements Runnable{

        @Override
        public void run() {
            while (!Thread.currentThread().isInterrupted()){
                System.out.println("我是" + Thread.currentThread().getName());
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread testThread = new Thread(new TestTask(), "test-thread");
        testThread.start();
        Thread.sleep(1000*5);
        testThread.interrupt();
    }
}
